package com.lemon.smartsafetynew.ui.adapter.work;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.lemon.smartsafety.entity.main.MainRcvItemBase;
import com.lemon.smartsafety.ui.adapter.common.RcvViewType;
import com.lemon.smartsafetynew.ui.adapter.common.SectionHeadViewNew;

import java.util.List;

import kale.adapter.LemonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Andrew on 2017/7/3.
 */

public class WorkFragmentAdapter extends LemonRcvAdapter<MainRcvItemBase> {

    private List<MainRcvItemBase> mItems;


    public WorkFragmentAdapter(@Nullable List<MainRcvItemBase> data) {
        super(data);
        this.mItems = data;
    }

    @Override
    public int getItemCount() {
        return this.mItems.size();
    }

    @Override
    public Object getItemType(MainRcvItemBase mainRcvItemBase) {
        return mainRcvItemBase.getViewType();
    }

    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        RcvViewType.MainRcvViewType myType = (RcvViewType.MainRcvViewType) type;

        if(myType == RcvViewType.MainRcvViewType.TYPE_CHART) {
            return new WorkChartViewRec();
        } else if (myType == RcvViewType.MainRcvViewType.TYPE_MAIN_OPTION) {
            return new WorkOptionItemViewRec();
        } else if (myType == RcvViewType.MainRcvViewType.TYPE_SECONDARY_OPTION) {
            //return new WorkSecondaryOptionItemViewRec();
            return new WorkSecondaryOptionItemViewRecNew();
        } else if (myType == RcvViewType.MainRcvViewType.TYPE_BANNER) {
            return new WorkBannerViewRec();
        }

        return new SectionHeadViewNew();
    }

}
